import Loading from '@/Loading';
import { dynamic } from 'umi';

const renderLoading = () => <Loading title="加载数据中" />;

const dynamicLoad = (url) => {
  return dynamic({
    loader: async () => {
      // 动态加载第三方组件
      const { default: DynamicComponent } = await import(
        /* webpackChunkName: "dynamic-component" */ '@/pages/' + url
      );
      return DynamicComponent;
    },
    loading: () => renderLoading(),
  });
};

const Home = dynamicLoad('Home');
const Table_HB = dynamicLoad('Table_HB');
const TransFromTable = dynamicLoad('TransFromTable');
const Demo_useRequest = dynamicLoad('Demo_useRequest');

export const menuConfigMap = {
  Home,
  Table_HB,
  TransFromTable,
  Demo_useRequest,
};
